@echo off
title 百日行动系统 - 快速测试
echo ==========================================
echo 百日行动线索收集系统 - 快速测试
echo ==========================================
echo.

echo 1. 设置环境变量...
set DB_HOST=localhost
set DB_PORT=3306
set DB_USER=root
set DB_PASSWORD=newhand
set DB_NAME=hunaction
set PORT=3001
set NODE_ENV=development

echo 2. 启动后端服务器...
cd backend
start /min cmd /c "echo 后端启动中... && node app.js"
cd ..

echo 3. 等待服务器启动...
timeout /t 5 /nobreak > nul

echo 4. 测试API连接...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:3001/api/health' -TimeoutSec 5; Write-Host '✅ 后端服务器运行正常'; Write-Host $response.Content } catch { Write-Host '❌ 后端服务器连接失败' }"

echo.
echo 5. 打开测试页面...
start http://localhost:3001/../frontend/debug_api.html
timeout /t 2 /nobreak > nul
start http://localhost:3001/../frontend/public/submit.html

echo.
echo ==========================================
echo 测试页面已打开：
echo - API调试页面 (用于测试API连接)
echo - 线索提交页面 (实际提交页面)
echo ==========================================
echo.
echo 如果页面无法打开，请：
echo 1. 检查后端服务器是否启动成功
echo 2. 确认数据库连接正常
echo 3. 使用浏览器直接访问：
echo    - http://localhost:3001/api/health
echo    - file:///[当前目录]/frontend/debug_api.html
echo.
pause 